package com.daohang361.imqq.decoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.tool.MyUtil;

/** 
 * @author naner E-mail:likun3344@163.com 
 * @create time：2011-4-20 下午07:26:32 
 *1F 00 00 00 00 
 *4A 00 00 
 *01 01 0D 
 *E5 A4 A7 E5 AD A6 66 72 69 65 6E 64 73 [大学friends]
 *02 02 0C 
 *E9 AB 98 E4 B8 AD E5 A5 BD E5 8F 8B [高中好友]
 *03 03 08 
 *20 66 72 69 65 6E 64 73 [friends]
 *04 04 0C 
 *E5 88 9D E4 B8 AD E5 90 8C E5 AD A6 [初中同学]
 *05 05 00 []
 *06 06 06 
 *E5 90 8C E4 BA 8B[同事]
 */
public class Decoder01 extends AbstractDecoder {
@Override
public QQUser decode() throws Exception {
	myArray.decryptRemain(sessionQQ.getAttr("SessionKey"));
	myArray.extract(0, 7);
	
	while(myArray.hasNext()){
		myArray.extract(0, 0);
	byte[] index=myArray.extract(0, 0);
	int tempLength=MyUtil.bytes2Integer(myArray.extract(0, 0));
	byte[] groupName=null;
	if(tempLength==0)
		groupName=new byte[0];
	else
		groupName=myArray.extract(0, tempLength-1);
	System.out.println("Int "+MyUtil.bytes2Integer(index)+":"+new String(groupName,"UTF-8"));
	sessionQQ.addFriendGroup(MyUtil.bytes2Integer(index),groupName);
	}
	sessionQQ.addFriendGroup(0,"我的好友".getBytes());
	sessionQQ.setLogintimes(sessionQQ.getLogintimes()+1);//登陆包前进
	sessionQQ.setPakage(sessionQQ.getPakage()+1);//登陆包自动增长
	return sessionQQ;
}
}
